/**
 * Copyright © 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
 */
package com.jeeplus.modules.ticketdata.unitdata.service;

import java.util.Date;
import java.util.List;

import com.jeeplus.common.utils.IdGen;
import com.jeeplus.modules.sys.entity.User;
import com.jeeplus.modules.sys.utils.UserUtils;
import com.jeeplus.modules.ticketdata.leadershipdata.entity.LeadershipData;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.service.CrudService;
import com.jeeplus.modules.ticketdata.unitdata.entity.UnitData;
import com.jeeplus.modules.ticketdata.unitdata.mapper.UnitDataMapper;

/**
 * 领导单位Service
 * @author 刘明星
 * @version 2021-10-29
 */
@Service
@Transactional(readOnly = true)
public class UnitDataService extends CrudService<UnitDataMapper, UnitData> {

	public UnitData get(String id) {
		return super.get(id);
	}
	
	public List<UnitData> findList(UnitData unitData) {
		return super.findList(unitData);
	}
	
	public Page<UnitData> findPage(Page<UnitData> page, UnitData unitData) {
		return super.findPage(page, unitData);
	}
	
	@Transactional(readOnly = false)
	public void save(UnitData unitData) {
		super.save(unitData);
	}

	@Transactional(readOnly = false)
	public void manysave(UnitData manysave) {
		/*
			循环插入数据
		 */
		for (UnitData testDataChild21 : manysave.getUnitleader()){
			if (testDataChild21.getId() == null){
				testDataChild21.setId(IdGen.uuid());
				if (UnitData.DEL_FLAG_NORMAL.equals(testDataChild21.getDelFlag())){
					User user = UserUtils.getUser();
					testDataChild21.setUpdateBy(user);
					testDataChild21.setCreateBy(user);
					testDataChild21.setUpdateDate(new Date());
					testDataChild21.setCreateDate(new Date());
					mapper.insert(testDataChild21);
				}
			}
		}

	}
	@Transactional(readOnly = false)
	public void delete(UnitData unitData) {
		super.delete(unitData);
	}
	
}